Skip to content

Add completion contributor for Bukkit event handlers#2613

Open
Leguan16 wants to merge 5 commits intominecraft-dev:devfrom
Leguan16:feat/bukkit-event-handler-completion-comtributor
Open

Add completion contributor for Bukkit event handlers#2613
Leguan16 wants to merge 5 commits intominecraft-dev:devfrom
Leguan16:feat/bukkit-event-handler-completion-comtributor

Conversation

@Leguan16
Copy link
Copy Markdown

Adds a completion contributor for Bukkit event handlers.

It only works in a class that implements org.bukkit.event.Listener.

It uses templates to generate the method and provide opportunity to change method name and parameter name.

Screen.Recording.2026-04-21.192030.mp4

I initially created this as a poc after someone (Strokkur) posted a video of him doing something similar and wanted to try if i can implement the same logic using the plugin SDK.

If this ends up getting added we can also add Strokkur as co-author for the idea if he wants to, i don't mind that.

@Strokkur424
Copy link
Copy Markdown
Contributor

That's cool

Copy link
Copy Markdown
Member

@Earthcomputer Earthcomputer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to my specific comments:

  • Please make sure to include license headers in all files.
  • The constants (inside the companion objects) should go in BukkitConstants. I believe some of them may already be there.


val eventNameFilter = prefix.substring(2).lowercase()

ClassInheritorsSearch.search(eventBaseClass, scope, true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks expensive. However it's not so easy to cache effectively because the easiest way to do that is using the PSI modification count as the cache key, and since you're in a completion provider that is changing on every keystroke. Leave it as it is for now.

Comment thread src/main/kotlin/platform/bukkit/completion/BukkitEventHandlerInsertHandler.kt Outdated
Comment thread src/main/kotlin/platform/bukkit/completion/BukkitEventHandlerInsertHandler.kt Outdated
Comment thread src/main/kotlin/platform/bukkit/completion/BukkitEventHandlerInsertHandler.kt Outdated
@Leguan16 Leguan16 force-pushed the feat/bukkit-event-handler-completion-comtributor branch from 3d708a9 to f8e9e4f Compare April 22, 2026 09:35
@Leguan16
Copy link
Copy Markdown
Author

I think i addressed everything in the requested changes. For the editable template I am not familiar enough with Kotlin to add this and currently don't have the time for it. If someone else wants to take a look feel free to do so.

If there is anything else that needs to be changed let me know.

@Leguan16 Leguan16 requested a review from Earthcomputer April 22, 2026 19:35
@Leguan16
Copy link
Copy Markdown
Author

Alright Strokkur added an editable live template so the auto completed method is now fully customizable.

it-works.mp4

I think - from my side - this is now ready for testing and another review. Let me know if you want anything changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants